package com.yonglian.management.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yonglian.management.domain.enumeration.ActivityPropertyType;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import java.io.Serializable;
import org.apache.logging.log4j.util.Strings;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * A ActivityProperty.
 */
@Entity(name = "activity_property")
@Table(name = "activity_property")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SuppressWarnings("common-java:DuplicatedBlocks")
public class ActivityProperty implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @NotNull
    @Size(min = 2, max = 50)
    @Column(name = "property_name", length = 50, nullable = false)
    private String propertyName;

    @Column(name = "property_value")
    private String propertyValue;

    @Column(name = "property_remark")
    private String propertyRemark;

    @Enumerated(EnumType.STRING)
    @Column(name = "property_type")
    private ActivityPropertyType propertyType;

    @Column(name = "order_no")
    private Integer orderNo;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "activity_id")
    @JsonIgnoreProperties(value = { "properties", "project" }, allowSetters = true)
    private Activity activity;

    public boolean isEmpty() {
        return (
            id == null &&
            Strings.isEmpty(propertyName) &&
            Strings.isEmpty(propertyValue) &&
            Strings.isEmpty(propertyRemark) &&
            propertyType == null &&
            orderNo == null
        );
    }

    // jhipster-needle-entity-add-field - JHipster will add fields here

    public Long getId() {
        return this.id;
    }

    public ActivityProperty id(Long id) {
        this.setId(id);
        return this;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPropertyName() {
        return this.propertyName;
    }

    public ActivityProperty propertyName(String propertyName) {
        this.setPropertyName(propertyName);
        return this;
    }

    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }

    public String getPropertyValue() {
        return this.propertyValue;
    }

    public ActivityProperty propertyValue(String propertyValue) {
        this.setPropertyValue(propertyValue);
        return this;
    }

    public void setPropertyValue(String propertyValue) {
        this.propertyValue = propertyValue;
    }

    public String getPropertyRemark() {
        return this.propertyRemark;
    }

    public ActivityProperty propertyRemark(String propertyRemark) {
        this.setPropertyRemark(propertyRemark);
        return this;
    }

    public void setPropertyRemark(String propertyRemark) {
        this.propertyRemark = propertyRemark;
    }

    public ActivityPropertyType getPropertyType() {
        return this.propertyType;
    }

    public ActivityProperty propertyType(ActivityPropertyType propertyType) {
        this.setPropertyType(propertyType);
        return this;
    }

    public void setPropertyType(ActivityPropertyType propertyType) {
        this.propertyType = propertyType;
    }

    public Integer getOrderNo() {
        return this.orderNo;
    }

    public ActivityProperty orderNo(Integer orderNo) {
        this.setOrderNo(orderNo);
        return this;
    }

    public void setOrderNo(Integer orderNo) {
        this.orderNo = orderNo;
    }

    public Activity getActivity() {
        return this.activity;
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    public ActivityProperty activity(Activity activity) {
        this.setActivity(activity);
        return this;
    }

    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof ActivityProperty)) {
            return false;
        }
        return getId() != null && getId().equals(((ActivityProperty) o).getId());
    }

    @Override
    public int hashCode() {
        // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
        return getClass().hashCode();
    }

    // prettier-ignore
    @Override
    public String toString() {
        return "ActivityProperty{" +
            "id=" + getId() +
            ", propertyName='" + getPropertyName() + "'" +
            ", propertyValue='" + getPropertyValue() + "'" +
            ", propertyRemark='" + getPropertyRemark() + "'" +
            ", propertyType='" + getPropertyType() + "'" +
            ", orderNo=" + getOrderNo() +
            "}";
    }
}
